import request from '@/utils/request'

/**
 * 查询企业的部门列表
 */
export const reqGetDepartments = () => {
  return request({
    method: 'get',
    url: '/company/department'
  })
}

/**
 * 删除部门
 * @param {*} id 部门 id
 */
export const reqDelDepartments = (id) => {
  return request({
    method: 'delete',
    url: `/company/department/${id}`
  })
}

/**
 * 新增部门
 * @param {*} obj {
 * code：部门编码
 * introduce：介绍
 * manager：部门负责人
 * name：部门名称
 * pid：所属部门 id
 * }
 */
export const reqAddDepartment = (obj) => {
  return request({
    method: 'post',
    url: '/company/department',
    data: obj
  })
}

/**
 * 根据 id 获取部门详情
 * @param {*} id 部门 id
 */
export const reqGetDepartDetail = (id) => {
  return request({
    url: '/company/department/' + id
  })
}

/**
 * 根据ID修改部门详情
 * @param {*} form 表单数据
 */
export const reqUpdateDepartments = (form) => {
  return request({
    method: 'put',
    url: `/company/department/${form.id}`,
    data: form
  })
}
